<?php

class Product_detail extends CI_Controller {

  function __construct() {
    parent::__construct();
    $this->load->helper('form', 'url');
    $this->load->model('m_sanpham');
    $this->load->model('m_categories');
  }

  function index() {
    
  }

  function view($id = null) {
    if (empty($id)) {
      echo '<center>';
      echo '<h2> Sorry product not found, please previous !';
      echo '</center>';
    } else {
      $data['categories'] = $this->m_categories->getcategoryparent();
      $data['quanaonam'] = $this->m_categories->getcategorycon(1, 1);
      $data['quanaonu'] = $this->m_categories->getcategorycon(2, 1);
      $data['header'] = $this->load->view('header', $data, TRUE);
      $data['sanpham'] = $this->m_sanpham->getProduct($id);
      $this->load->view('product', $data);
    }
  }

}
